import request from '@/utils/request'
import type { ApiResult, BaseIds, Kv, PageSchema } from '@/api/api'
import type {
  Machine,
  MachineAddDTO,
  MachineModDTO,
  MachineQueryDTO,
} from '@/api/ops/machine/type'
const baseUrl = '/admin/api/v1/ops/machine'
const API = {
  BASE_URL: baseUrl,
  PAGE_URL: baseUrl + '/page',
  LIST_URL: baseUrl + '/list',
  REMOVE_URL: baseUrl + '/rm',
  SOURCE_URL: baseUrl + '/source',

} as const;
// 添加机器信息
export const machineAdd = (data: MachineAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 修改机器信息
export const machineMod = (data: MachineModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 删除机器信息
export const machineDel = (data: BaseIds) => {
  return request.post<any, ApiResult<unknown>>(API.REMOVE_URL, data)
}
// 查询机器信息
export const machineList = (data: MachineQueryDTO) => {
  return request.post<any, ApiResult<Machine[]>>(API.LIST_URL, data)
}
// 查询分页数据
export const machineQuery = (data: MachineQueryDTO) => {
  return request.post<any, ApiResult<PageSchema<Machine>>>(API.PAGE_URL, data)
}

export const source = (id: string) => {
  return request.get<any, ApiResult<Kv>>(API.SOURCE_URL + '/' + id)

}

